package com.hclc.util.poi;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @ClassName ExcelCellTypeEnums
 * @Author: yurj
 * @Mail：1638234804@qq.com
 * @Date: Create in 15:27 2020-4-10
 * @version: 1.0
 */
public enum  ExcelCellTypeEnums{

    TYPE_LONG(0,"Long"),
    TYPE_STRING(1,"String"),
    TYPE_INTEGER(2,"Integer"),
    TYPE_DOUBLE(3,"Double"),
    TYPE_BIG_DECIMAL(4,"BigDecimal"),
    TYPE_LOCAL_DATE(5,"LocalDate"),
    TYPE_LOCAL_DATE_TIME(6,"LocalDateTime");


    @JsonValue
    private final int code;

    private final String desc;
    ExcelCellTypeEnums(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getDesc(){return desc;}
    public static ExcelCellTypeEnums find(String desc ) throws IllegalArgumentException{
        for (ExcelCellTypeEnums model : ExcelCellTypeEnums.values()) {
            if (model.getDesc().equals(desc)) {
                return model;
            }
        }
        throw new IllegalArgumentException();
    }
    @JsonCreator
    public static ExcelCellTypeEnums find(int code ) throws IllegalArgumentException{
        for (ExcelCellTypeEnums model : ExcelCellTypeEnums.values()) {
            if (model.code == code) {
                return model;
            }
        }
        throw new IllegalArgumentException();
    }
}
